<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    function HashFunc(str,size) {
        //定义储存变量
        var count = 0;
        for (var i=0;i<str.length;i++){
            //获取对应unicode码
            count = count * 37 + str.charCodeAt(i);
        }
        var index = count % size;

        return index;
    }
    alert(HashFunc('abc',7))
    alert(HashFunc('bbc',7))
    alert(HashFunc('cbc',7))
    alert(HashFunc('dbc',7))
    alert(HashFunc('nbc',7))
    alert(HashFunc('mbc',7))
    alert(HashFunc('ybc',7))
</script>
</body>
</html>